import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
// import store from './store'
import axios from 'axios'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import '@/styles/index.scss'
// 第一步：引入pinia
import { createPinia } from 'pinia'


const app = createApp(App)

//全局注册 Axios 和 Element Plus Icons Vue 组件
app.config.globalProperties.$axios = axios
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

// router.beforeEach((to, from, next) => {
//     // 根据当前路由的路径，手动激活对应的菜单项
//     const currentRoute = to.path;
//     const menuItems = document.querySelectorAll('.el-menu-item');

//     menuItems.forEach(item => {
//         if (item.getAttribute('index') === currentRoute) {
//             item.classList.add('is-active');
//         } else {
//             item.classList.remove('is-active');
//         }
//     });

//     next();
// });
// 第二步：创建pinia
const pinia = createPinia()


// 第三步：安装pinia
app.use(pinia)
app.use(router)
app.use(ElementPlus, {
    locale: zhCn,
})
app.mount('#app')

